<template>
    <div v-if="change && show">
        <div v-if="change > 0">
            <el-badge :value="change">
                {{ current }}
            </el-badge>
        </div>
        <div v-if="change == 0">
            {{ current }}
        </div>
        <div v-if="change < 0">
            <el-badge :value="change" type="warning">
                {{ current }}
            </el-badge>
        </div>
    </div>
    <div v-else>
        {{ current }}
    </div>
</template>

<script>

export default {
    name: "badge",
    data() {
        return {}
    },
    // 这里定义需要父组件传过来的东西
    props: {
        current: {
            type: Number,
        },
        change: {
            type: Number,
        },
        show: {
            type: Boolean,
            default: true
        }
    },
    methods: {},
    watch: {
        current: function (val, oldVal) {
            this.current = val;
        },
        change: function (val, oldVal) {
            this.change = val;
        },
        show: function (val, oldVal) {
            this.show = val;
        }
    },
    created() {
    },
}
</script>

